IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id('dbo.stat_user') AND OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE dbo.stat_user
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id('dbo.stat_file') AND OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE dbo.stat_file
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id('dbo.stat_ip') AND OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE dbo.stat_ip
GO

CREATE TABLE dbo.stat_user(
  ID int IDENTITY(1,1) PRIMARY KEY NOT NULL,
  _USER varchar(255) NOT NULL,
  CONN int NOT NULL,
  DOWN_FILE int NOT NULL,
  DOWN_MB decimal(32,2) NOT NULL,
  DOWN_PERCENT decimal(6,2),
  UP_FILE int NOT NULL,
  UP_MB decimal(32,2) NOT NULL,
  UP_PERCENT decimal(6,2),
  STAT_TIME datetime NOT NULL,
  CREATE_TIME datetime NOT NULL
)
GO

CREATE TABLE dbo.stat_file(
  ID int IDENTITY(1,1) PRIMARY KEY NOT NULL,
  FILE_COUNT int NOT NULL,
  FILE_NAME varchar(512) NOT NULL,
  STAT_TIME datetime NOT NULL,
  CREATE_TIME datetime NOT NULL
)
GO

CREATE TABLE dbo.stat_ip(
  ID int IDENTITY(1,1) PRIMARY KEY NOT NULL,
  IP varchar(255) NOT NULL,
  CONN int NOT NULL,
  DOWN_FILE int NOT NULL,
  DOWN_MB decimal(32,2) NOT NULL,
  DOWN_PERCENT decimal(6,2),
  UP_FILE int NOT NULL,
  UP_MB decimal(32,2) NOT NULL,
  UP_PERCENT decimal(6,2),
  STAT_TIME datetime NOT NULL,
  CREATE_TIME datetime NOT NULL
)
GO
